# Makefile for MentOS

# Temporary
# x86_64-elf
# i586-elf
TARGET=x86_64-elf
CC=$(TARGET)-gcc
CFLAGS=-Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs
KERNEL_RELEASE_FOLDER =releaseX/$(TARGET)/kernel
YASM=yasm -f elf64

# Temporary
all: kernel

test:
	mkdir -p releaseX/$(TARGET)/test/
	$(CC) $(CFLAGS) ../test/main.c -o releaseX/$(TARGET)/test/test.o 

kernel:
	mkdir -p $(KERNEL_RELEASE_FOLDER)
	$(YASM) -o $(KERNEL_RELEASE_FOLDER)/multiboot_loader.o ../kernel/multiboot_loader.asm
	$(CC) $(CFLAGS) ../kernel/main.c -o $(KERNEL_RELEASE_FOLDER)/kernel.o
	$(TARGET)-ld -T ../kernel/linker.ld -o $(KERNEL_RELEASE_FOLDER)/kernel.bin $(KERNEL_RELEASE_FOLDER)/multiboot_loader.o $(KERNEL_RELEASE_FOLDER)/kernel.o
	cat ../kernel/stage1 ../kernel/stage2 ../kernel/pad $(KERNEL_RELEASE_FOLDER)/kernel.bin > $(KERNEL_RELEASE_FOLDER)/floppy.img
	cp ../kernel/bochsrc.txt $(KERNEL_RELEASE_FOLDER)